package com.example.ywj.toutiao;

import android.content.Intent;
import android.os.Build;
import androidx.annotation.Nullable;
//import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

import com.example.ywj.toutiao.utils.SlideFragment;
import com.example.ywj.toutiao.utils.SpUtils;

//import com.example.ywj.toutiao.utils.SpUtils;
import com.github.paolorotolo.appintro.AppIntro2;

public class AppIntroActivity extends AppIntro2 {

    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//因为不是所有的系统都可以设置颜色的，在4.4以下就不可以。。有的说4.1，所以在设置的时候要检查一下系统版本是否是4.1以上
            Window window = getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(getResources().getColor(R.color.trgray));
        }
        addSlide(SlideFragment.newInstance(R.layout.guide_page1));
        addSlide(SlideFragment.newInstance(R.layout.guide_page2));
        addSlide(SlideFragment.newInstance(R.layout.guide_page3));
        addSlide(SlideFragment.newInstance(R.layout.guide_page4));
        //setProgressButtonEnabled(false);
        showSkipButton(true);
    }
    @Override
    public void onSkipPressed() {
        //当执行跳过动作时触发
        Intent intent = new Intent(AppIntroActivity.this, MainActivity.class);
        startActivity(intent);
        SpUtils.putBoolean(AppIntroActivity.this, AppConstants.FIRST_OPEN, true);
        finish();
    }

    @Override
    public void onNextPressed() {
        //当执行下一步动作时触发
    }

    @Override
    public void onDonePressed() {
        //当执行完成动作时触发
        Intent intent = new Intent(AppIntroActivity.this, MainActivity.class);
        startActivity(intent);
        SpUtils.putBoolean(AppIntroActivity.this, AppConstants.FIRST_OPEN, true);
        finish();
    }

    @Override
    public void onSlideChanged() {
        //当执行变化动作时触发
    }
    public class AppConstants {
        public static final String FIRST_OPEN = "first_open";
    }


}
